import { Injectable } from '@nestjs/common';

import { InfluxDB, IResults, ISingleHostConfig } from 'influx';
import * as influx from 'influx';

export interface IEquipmentData {
  time: string | influx.INanoDate;
}

@Injectable()
export class EquipmentDataService {
  private client: InfluxDB;

  constructor() {
    const options: ISingleHostConfig = {
      host: '172.17.0.1',
      port: 8086,
      database: 'equipmenttest3',
    };
    this.client = new InfluxDB(options);
  }

  public async query(query: string): Promise<IResults<IEquipmentData>> {
    return this.client.query(query, { precision: 'n' });
  }
}
